package com.library.domain.vo;

import lombok.Data;

import java.util.ArrayList;
import java.util.List;

/**
 * @author : 凉小天
 * @date : 2021/6/30 14:32
 */
@Data
public class LoginUser {
    private static int visitCount = 0;
    private static final List<User> userList = new ArrayList<>();
    private static String token;
    private static String role;
    private static Long userId;

    public static void addVisitCount(){
        LoginUser.visitCount++;
    }

    public static int getVisitCount(){
        return LoginUser.visitCount;
    }

    /**
     * 添加登录用户
     */

    public static void addUser(String token,String role,Long userId){
        User user = new User(token,role,userId);
        userList.add(user);
    }
    public static User getUserByToken(String token){
        for (User user : userList) {
            if (user.getToken().equals(token)){
                return user;
            }
        }
        return null;
    }
}
